﻿using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;

namespace SerialPortTool.Unity
{
    public class SerialPortBase
    {

        string[] baudRate = { "9600", "19200", "38400", "57600", "115200" };
        string[] dataBit = { "5", "6", "7", "8" };
        string[] checkBit = { "None", "Even", "Odd", "Mask", "Space" };
        string[] stopBit = { "None", "One", "Two", "OnePointFive" };

        /// <summary>
        /// 波特率设置
        /// </summary>
        public string[] BaudRate { get; set; }

        /// <summary>
        /// 数据位设置
        /// </summary>
        public string[] DataBit { get; set; }

        /// <summary>
        /// 校验位设置
        /// </summary>
        public string[] CheckBit { get; set; }

        /// <summary>
        /// 停止位设置
        /// </summary>
        public string[] StopBit { get; set; }


        public SerialPortBase()
        {
            BaudRate = baudRate;
            DataBit = dataBit;
            CheckBit = checkBit;
            StopBit = stopBit;
        }


        /// <summary>
        /// 获取本机串口号
        /// </summary>
        public string[] GetNativePortNames()
        {
            return SerialPort.GetPortNames();
        }

        /// <summary>
        /// 日志
        /// </summary>
        public ILog Logger { get; set; }


    }
}
